<template>
  <div>
<el-dialog
  title="
  编辑"
  v-model="editDialogVisble"
  width="30%"
  center>
 <el-form ref="form" :model="form" label-width="80px">
  <el-form-item label="数目">
    <el-input v-model="form.income"></el-input>
  </el-form-item>
    <el-form-item label="描述">
    <el-input v-model="form.describe"></el-input>
  </el-form-item>
      <el-form-item label="详细描述">
    <el-input v-model="form.remark"></el-input>
  </el-form-item>
        <el-form-item label="用途">
    <el-input v-model="form.expend"></el-input>
  </el-form-item>
  

  <el-form-item label="类型">
 <el-radio v-model="form.type" label="收入" value="收入">收入</el-radio>
  <el-radio v-model="form.type" label="支出" value="支出">支出</el-radio>
  </el-form-item>
  <el-form-item label="支付方式">
 <el-radio v-model="form.cash" label="现金" value="现金">现金</el-radio>
  <el-radio v-model="form.cash" label="非现金" value="非现金">非现金</el-radio>
  </el-form-item>
</el-form>
  <template #footer>
    <span class="dialog-footer">
      <el-button @click="editDialogVisble = false">取 消</el-button>
      <el-button type="primary" @click="add">确 定</el-button>
    </span>
  </template>

</el-dialog>
  </div>
</template>

<script>
import {reqaddprofile} from "@api/profile.js" 
import { mapMutations } from 'vuex';
export default {
name:'addProfile',
data(){
    return {
        editDialogVisble:false,
        form:{
            type:"收入",
            income:"",
            expend:"",
            cash:"现金",
            remark:"",
            describe:"",
           
        },
      
    }
},
methods:{
    ...mapMutations({
      addProfile:"addProfile"
    }),
    // 打开修改框
    openEditDialog(){
       
      
        this.editDialogVisble=true
        
    },
   async add(){
     const result=  await reqaddprofile(this.form,{},{headers: {'Content-Type': 'application/x-www-form-urlencoded'},})
     console.log(result);
      this.addProfile(result)
       if (result) {
          this.editDialogVisble=false  
        }

    }
}
}
</script>

<style>

</style>